package oop.core;
import java.util.HashMap;
import java.util.Map;

public class Library<E>
{
	private Map<String, E> library = new HashMap<String, E>();
	private int numItems = 0;
	
	public int getNumItems(){
		return numItems;
	}
	
	public void addToLibrary(E elem, String name)
	{
		if(!library.containsKey(name))
		{
			library.put(name, elem);
			numItems++;
		}
	}
	
	/*
	 * This method assumes you filter your removals prior to calling this method. 
	 */
	public E removeElemFromLibrary(String name)
	{
		E elem = library.remove(name);
		numItems--;
		return elem;
	}
	
	public E getFromLibrary(String name)
	{
		return library.get(name);
	}
}